<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>z-index</title>
  <style>
    .div1,
    .div2 {
      width: 100px;
      height: 100px;

    }

    .div1 {
      background-color: lavender;
      /* 相对定位 */
      position: relative;
      top: 50px;
      left: 50px;
      /* 此时紫色在上 需求：黄色在上 解决方案：z-index */
      z-index: -1;

    }

    .div2 {
      background-color: lemonchiffon;
    }
  </style>
</head>

<body>
  <!-- z-index为了解决元素堆叠顺序属性 
  置于顶层
  置于底层
  -->
  <div class="div1"></div>
  <div class="div2"></div>

</body>

</html>